﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using DevExpress.Web.ASPxUploadControl;
using DevExpress.Web.ASPxClasses.Internal;

namespace Customer_Profile.eCard
{
    public partial class Temp : System.Web.UI.Page
    {
        const string UploadDirectory = "~/tempUpload/";
        const int ThumbnailSize = 100;

        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write(DateTime.Now.ToString("yyyyMMddHHmmssfff"));
            Response.Write("<br>");
            //Response.Write(DateTime.Now.to);
            if (IsPostBack)
                UploadControl.ShowProgressPanel = true;
        }

        protected string SavePostedFiles(UploadedFile uploadedFile)
        {
            string strTemp = Session["deal_no"].ToString();
            string ret = "";
            if (uploadedFile.IsValid)
            {
                FileInfo fileInfo = new FileInfo(uploadedFile.FileName);
                string resFileName = MapPath(UploadDirectory) + fileInfo.Name;
                uploadedFile.SaveAs(resFileName);

                string fileLabel = fileInfo.Name;
                string fileType = uploadedFile.PostedFile.ContentType.ToString();
                string fileLength = uploadedFile.PostedFile.ContentLength / 1024 + "K";
                ret = string.Format("{0} <i>({1})</i> {2}|{3}", fileLabel, fileType, fileLength, fileInfo.Name);
            }
            return ret;
        }
        protected void UploadControl_FileUploadComplete(object sender, FileUploadCompleteEventArgs e)
        {
            try
            {
                e.CallbackData = SavePostedFiles(e.UploadedFile);
            }
            catch (Exception ex)
            {
                e.IsValid = false;
                e.ErrorText = ex.Message;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            HiddenField1.Value = "show me the money";
            Session["deal_no"] = "123456";
        }
    }
}